//
//  NSString+deviceToken.m
//  FZAH
//
//  Created by Yoga on 2017/4/10.
//  Copyright © 2017年 zdqk. All rights reserved.
//

#import "NSString+deviceToken.h"

@implementation NSString (deviceToken)

+ (NSString *)transformFromDeviceToken:(NSData *)deviceToken {
    if (!deviceToken) {
        return nil;
    }
    
    NSString *tokeStr = [NSString stringWithFormat:@"%@",deviceToken];
    // 字符串长度
    NSInteger stringLenght = [tokeStr lengthOfBytesUsingEncoding:NSUTF32StringEncoding]/4;
    NSString *tempStr = [tokeStr substringWithRange:NSMakeRange(1,stringLenght-1)];
    NSString *tempToStr = [tempStr substringToIndex:tempStr.length-1];
    
    NSMutableString *mutableString = [[NSMutableString alloc] init];
    NSArray<NSString *> *spArray = [tempToStr componentsSeparatedByString:@" "];
    for (NSString *temp in spArray) {
        [mutableString appendString:temp];
    }
    NSString *finalDeviceToken = [NSString stringWithString:mutableString];
    
    return finalDeviceToken;
}

@end
